<template>
  <div class="article-content">
    <c-title :hide="false" text=""></c-title>
    <h4>{{ dataInfo.title }}</h4>
    <div class="time">
      <span class="author">{{ dataInfo.author }}</span>
      <span class="time-created-at">{{ dataInfo.virtual_at ? dataInfo.virtual_at : dataInfo.created_at }}</span>
    </div>
    <div class="content">
      <div v-html="content" id="con" @click="handleHtml($event)"></div>
    </div>
    <div class="foot_advs" @click="toAdvs()" v-if="is_advs_type">
      <p class="advs_title">{{ dataInfo.advs_title }}</p>
      <div class="advs_img_bg" v-if="dataInfo.advs_img">
        <img class="advs_img" :src="dataInfo.advs_img" />
      </div>
      <div class="advs_img_bg" v-else>
        <img class="advs_img" src="../../assets/images/img_default.png" />
      </div>
      <div class="advs_desc">{{ dataInfo.advs_title_footer }}</div>
    </div>

    <div class="qrCode" v-if="codeUrl && isShowCode">
      <div class="code">
        <div class="img">
          <img :src="codeUrl" />
        </div>
        <span>长按识别二维码</span>
      </div>
    </div>

    <div class="flex-j-sb flex-a-c" style="margin-bottom: 12px;" v-if="dataInfo.has_one_store">
      <div class="flex-a-c">
        <i class="iconfont icon-dianpu" style="margin-right: 0.25rem;"></i>
        <div class="line-clamp-1 f-bold f-15" style="width: 10rem;">{{dataInfo.has_one_store.store_name}}</div>
      </div>
      <van-button type="warning" color="#ef3532" round size="mini" @click.stop="toUrl('HomeSeller',{'store_id': dataInfo.has_one_store.id })">进入门店</van-button>
    </div>

    <div class="foot">
      <div class="read">阅读 {{ read_num }}</div>
      <div class="foot-right">
        <div  v-if="is_report_enabled" class="report"  @click="report()">
          <i class="iconfont icon-report"></i>
          <span>举报</span>
        </div>
        <div  v-if="is_link" class="link"  @click="link()">阅读原文</div>
        <div v-if="show_poster && !comment" @click="showPost">
          <i class="iconfont icon-fontclass-fenxiang2222" style="margin-right: 0;"></i>
        </div>
      </div>
    </div>


    <div class="comment" v-if="comment">
      <div class="comment-title">评论详情</div>
      <div class="commentList">
        <template v-if="commentList&&commentList.length!==0">
          <div class="firstComment" v-for="(item, ind) in commentList" :key="ind" @click.stop="delComment(item, ind)">
            <div class="userTop">
              <div style="display: flex;align-items: center;">
                <div class="user-image">
                  <img :src="item.head_image" alt="" />
                </div>
                <div class="nick-name">{{ item.nick_name }}</div>
              </div>
              <div class="user">
                <div class="contenBox">
                  <div class="txt">{{ item.content }}</div>
                  <div class="contenImg" v-if="item.comment_images.length > 0" @click.stop="watchImg(item.comment_images)">
                    <img :src="item.comment_images" alt="" />
                  </div>
                </div>
                <div style="display: flex;align-items: center;justify-content: space-between;">
                  <div class="created-at">{{ item.created_at }}</div>
                  <div class="reply" @click.stop="replyBtn(item.nick_name, item, ind)">回复</div>
                </div>
              </div>
            </div>
            <!-- 回复的评论 -->
            <div class="commentLis" v-show="item.child" v-for="(info, index) in item.child" :key="index" @click.stop="delComment(info, ind, index, 'child')">
              <div class="commentLis-user-top">
                <div style="display: flex;align-items: center;">
                  <div class="image">
                    <img :src="info.head_image" alt="" v-if="info.head_image" />
                    <img src="../../assets/images/photo-mr.jpg" alt="" v-else />
                  </div>
                  <div class="user-name">{{ info.nick_name }}</div>
                </div>
                <div class="commentLis-user">
                  <div class="contenBox">
                    <div class="txt" v-if="info.reply_id != '0' || info.reply_name" style="text-align: left;padding-left: 2.0625rem;margin-bottom: 0.3125rem;">回复{{ info.reply_name }}:</div>
                    <div class="commentLis-user-content">{{ info.content }}</div>
                    <div class="commentLis-user-img" v-if="info.comment_images" @click.stop="watchImg(info.comment_images)">
                        <template v-for="(datas, indkey) in info.comment_images" >
                          <img   :src="datas"   :key="indkey"/>
                        </template >
                    </div>
                  </div>
                </div>
                <div class="commentLis-user-bottom" >
                  <div class="dateDay">{{ info.updated_at }}</div>
                  <div class="reply" @click.stop="replyBtn(info.nick_name, info, ind)">回复</div>
                </div>
              </div>
            </div>
            <!-- 展开更多 加在更多评论 -->
            <div class="commentLis" v-if="item.reply_num > 0 && item.commentShow">
              <div class="commentMore" @click.stop="moreCommentLis(item.id, ind)">
                显示展开{{ item.reply_num }}条回复
                <van-icon name="arrow-down" />
              </div>
            </div>
          </div>
          <div class="commentMore" v-if="commentPage < last_page" @click="getMore">
            展开更多的评论
            <van-icon name="arrow-down" />
          </div>
        </template>
        <template v-else>
          <div class="no-comment">暂无评论</div>
        </template>
      </div>

      <!-- 回复输入框 -->
      <div class="replyInp" :class="{'w375': fun.isPc()}">
        <div class="inpNav" @click="subMainCommentBtn">
          <input :disabled="showCommentInput"  type="text" placeholder="来都来了，留下点什么吧"  />
        </div>
        <div class="replyInp-right">
          <div v-if="show_poster || this.fun.isXueXiApp()" @click="openShare">
            <i class="iconfont icon-fontclass-fenxiang2222"></i>
          </div>
          <div v-if="dataInfo.donate_open" @click="showDonate = true">
            <i class="iconfont icon-bc_pay_discount"></i>
          </div>
          <div  @click="like(like_num)">
            <i :class="is_liked?'iconfont icon-zb_like':'iconfont icon-dianzan'"></i>
            <span>{{like_num}}</span>
          </div>
          <div>
            <i class="iconfont icon-comment"></i>
            <span>{{ commentNum }}</span>
          </div>
        </div>
      </div>
      <yz-comment-input v-model="showCommentInput" v-on:confirm="subMainBtn" :options="commentInputOptions" :openImg="false">
        <!-- <div class="commentInput-slot-style" v-if="commentInputOptions.type == 'reply'">
          回复<span class="selcolor">@{{ replyName }}</span>
        </div> -->
      </yz-comment-input>
    </div>

    <!-- 分享弹窗 -->
    <van-share-sheet v-model="showShare" title="立即分享给好友" :options="shareSheetOptions" @select="onSelectShareSheet"/>
    <van-image-preview v-model="showImg" :images="imgList" :start-position="imgStart"></van-image-preview>
    <yz-goodsposter v-model="posterShow" :posterData="isFrontCanvas ? posterImg : {}" :defaultImg="!isFrontCanvas ? posterImg : ''" ></yz-goodsposter>

    <van-popup v-model="showDonate" position="bottom" round closeable>
      <van-nav-bar title="捐赠"/>
      <div style="margin: 0 0.875rem;">
        <div class="f-16 t-l" style="line-height: 3.5rem;">请选择捐赠{{ fun.getCustomTextLang('member_center.credit1','积分') }}</div>
        <div class="activityItem" >
          <!-- 自定义充值金额 -->
          <div class="acitem" :class="{'activeAcitemStyle': diy_money_index == index}" v-for="(item, index) in diy_amount" :key="index" @click.stop="selectDiyNum(index)">
            <div class="left f-20 f-bold">{{ item }}</div>
          </div>
          <div class="acitem" :class="{'activeAcitemStyle': diy_money_index == diy_amount.length}" @click.stop="selectDiyNum(diy_amount.length)">
            <input class="f-13" type="number" v-model.trim="diymoney" :placeholder="`自定义捐赠${fun.getCustomTextLang('member_center.credit1','积分')}`"/>
          </div>
        </div>

        <van-button @click="subDonate" round type="info" block style="margin: 1.5rem 0 2rem;" color="var(--themeBaseColor)">确认捐赠</van-button>
      </div>
    </van-popup>

  </div>
</template>
<script>
import articleContent_controller from "./articleContent_controller";
export default articleContent_controller;
</script>

<style>
/* 覆盖内联样式 */
.article-content .content {
  word-break: break-all;
}

.article-content .content div,
.article-content .content section,
.article-content .content p,
.article-content .content ul,
.article-content .content ol {
  max-width: 100%;
}

.article-content .content ul {
  list-style-type: disc;
}

.article-content .content ol {
  list-style-type: decimal;
}

.article-content .content img {
  display: block;
  max-width: 100% !important;
  height: auto !important;
}

.article-content .content {
  list-style-type: revert;
}
</style>
<style lang="scss" rel="stylesheet/scss" scoped>
.w375{
  width: 375px;
  position: fixed;
  left: 50% !important;
  transform: translateX(-50%) !important;
}
.article-content {
  background: #fff;
  padding: 1rem;
  overflow-x: hidden;

  .contenBox {
    padding: 0.625rem 0;
  }

  .foot_advs {
    margin-bottom: 1.25rem;
    height: auto;
    background: #fff;
    width: 100%;
    border-radius: 0;
  }

  .qrCode {
    background: #fff;
    margin-top: 0.625rem;
    padding-bottom: 2.9688rem;

    h3 {
      height: 2.5rem;
      line-height: 2.5rem;
      font-size: 16px;
      text-align: left;
      padding: 0 0.875rem;
    }

    .code {
      span {
        color: #8c8c8c;
      }

      .img {
        width: 7.5rem;
        height: 7.5rem;
        overflow: hidden;
        background: #f5f5f5;
        margin: 0.625rem auto;

        img {
          width: 100%;
        }
      }
    }
  }

  .foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2.0625rem;
  }

  h4 {
    text-align: left;
    font-size: 18px;
  }

  h4.like {
    float: left;
    color: #8a8a8a;
    text-align: left;
    font-size: 16px;
  }
  .foot-right{
    display: flex;
    align-items: center;
  }

  .read{
    padding-right: 0.625rem;
    color: #AAAAB3;
    text-align: left;
    font-size: 0.875rem;
  }

  .report,  .link  {
    padding-right: 0.625rem;
    color: #AAAAB3;
    font-size: 0.875rem;
  }
  .report{
    display: flex;
    align-items: flex-end;
    .icon-report{
      margin-right: 0.125rem;
    }
  }

  h4.copy {
    padding-right: 0.625rem;
    float: left;
    color: #8a8a8a;
    text-align: left;
    font-size: 16px;
  }
  .time {
    display: flex;
    align-items: center;
    text-align: left;
    line-height: 1.5625rem;
    height: 1.5625rem;
    margin-bottom: 1.25rem;
    margin-top: 0.8438rem;
  }
  .author{
    color: #3B3B4A;
    font-size: 0.875rem;
    margin-right: 0.625rem;
  }
  .time-created-at{
    color:#AAAAB3;font-size: 0.8125rem;
  }
  .content {
    width: 100%;
    font-size: 16px;
    text-align: left;
    padding-top: 0.625rem;
    padding-bottom: 1.875rem;
    word-break: break-all;

    img {
      width: 100%;
    }

    li {
      list-style: inherit;
    }
  }

  .advs_img_bg {
    width: 100%;
    margin-top: 1rem;
    margin-bottom: 1.7813rem;
    border-radius: 0.75rem;
    overflow: hidden;
  }

  .advs_img {
    width: 100%;
  }

  p.advs_title {
    text-align: left;
    height: 1.875rem;
    line-height: 1.875rem;
    font-size: 1rem;
    font-weight: 400;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .advs_desc {
    text-align: left;
    font-size: 1rem;
    color: #00001C;
    font-weight: 400;
  }
}
// 文章评论
.commentInput-slot-style {
  height: 1.5rem;
  line-height: 2rem;
  text-align: left;
  padding-left: 0.875rem;

  .selcolor {
    color: #1c96fe;
  }
}

.commentMore {
  font-size: 0.81rem;
  color: #4d88df;
  display: flex;
  justify-content: center;
  align-items: center;
}

.comment {
  background-color: #fff;
  padding-bottom: 10rem;
  .no-comment{
    color:#AAAAB3;
    margin-top: 1.875rem;
    margin-bottom: 7.7188rem;
  }
  .comment-title{
    border-top: 1px solid #F0F0F1;
    font-size: 1.125rem;
    color: #00001C;
    font-weight: bold;
    padding: 1.4375rem 0 0;
    text-align: left;
  }

  .replyInp {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    height: 3.75rem;
    background-color: #fff;
    border-top: 1px solid #F0F0F1;
    padding-left: 0.9375rem;
    padding-right: 0.875rem;
    display: flex;
    align-items: center;z-index:10;

    .userImg {
      width: 2.19rem;
      height: 2.19rem;
      border-radius: 100%;

      img {
        width: 2.19rem;
        height: 2.19rem;
        border-radius: 100%;
      }
    }

    .inpNav {
      width: 12.5rem;
      height: 2.5rem;
      background: #f5f5f5;
      border-radius: 1.25rem;
      padding-left: 1rem;
      z-index: 5;

      input {
        width: 100%;
        height: 100%;
        outline: none;
        border: none;
        z-index: 1;
      }
    }
  }

  .title {
    font-size: 1rem;
    color: #202020;
    text-align: left;
    padding-top: 1.06rem;
    padding-left: 0.97rem;
    padding-bottom: 1.16rem;
    box-sizing: border-box;
  }


  .commentList {
    // padding: 1.13rem 0.94rem;
    .commentLis-user-img{
      padding-left: 2.0625rem;
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      img{
        width: 3rem !important;
        height: 3rem !important;
        background-color: #c1c1c1;
        border-radius: 0.13rem;
        margin: 0;
        margin-right: 0.25rem;
        border-radius: 0 !important;
      }
    }
    .commentLis-user-bottom{
      display: flex;align-items: center;justify-content: space-between;
      padding-left: 2.0625rem;
      .dateDay{
        color: #AAAAB3;
        font-size: 0.75rem;
      }
      .reply{
        width: 2.375rem;
        text-align: center;
        height: 1.25rem;
        line-height: 1.25rem;
        background: #F0F0F1;
        border-radius: 0.9063rem;
        font-size: 0.75rem;
      }
    }
    .commentLis-user-content{
      text-align: left;
      padding-left: 2.0625rem;
      font-size: 0.875rem;
      font-weight: 400;
      color: #00001C;
    }
   .commentLis-user-top{
      img{
        width: 1.5rem;
        height: 1.5rem;
        border-radius: 100%;
      }
      .user-name{
        font-size: 0.8125rem;
        font-weight: 400;
        color: #818181;
        margin-left: 0.5625rem;
      }
    }
    .created-at{
      color: #AAAAB3;
      font-size: 0.75rem;
      font-weight: 400;
    }
    .user-image{
      width: 2rem;
      height: 2rem;
      margin-right: 0.5625rem;
      img{
        width: 100%;
        height: 100%;
        border-radius: 100%;
      }
    }
    .nick-name{
      font-size: 0.8125rem;
      font-weight: 400;
      color: #6E6E79;
    }

    .firstComment {
      margin-top: 1.4063rem;
      .userTop {
        .user {
          text-align: left;
          padding-left:2.5625rem;
          height: 100%;

          .userName {
            font-size: 1rem;
            color: #2e2e2e;
          }

          .dateDay {
            font-size: 0.63rem;
            color: #767676;
          }

          .contenBox {
            padding: 0 !important;
            margin-bottom: 0.625rem;
            width: 100%;

            .txt {
              font-size: 0.875rem;
              color: #2e2e2e;
              display: flex;
            }

            .contenImg {
              display: flex;
              justify-content: flex-start;

              img {
                width: 3rem;
                height: 3rem;
                background-color: #c1c1c1;
                border-radius: 0.13rem;
                margin: 0;
                margin-right: 0.25rem;
              }
            }
          }
        }

        .image {
          width: 2.5rem;
          height: 2.5rem;
          background-color: #b5b5b5;
          border-radius: 50%;
          margin-right: 0.63rem;

          img {
            width: 2.5rem;
            height: 2.5rem;
            border-radius: 50%;
          }
        }

        .reply {
          font-size: 0.6875rem;
          letter-spacing: 0.02rem;
          color: #00001C;
          background: #F0F0F1;
          border-radius: 0.9063rem ;
          width: 2.375rem;
          height: 1.25rem;
          text-align: center;
          line-height: 1.25rem;
        }
      }

      .commentLis {
        margin-top: 0.94rem;
        margin-left: 2.5625rem;

        .userTop {
          display: flex;

          .user {
            flex: 1;
            text-align: left;
            height: 100%;

            .userName {
              font-size: 0.88rem;
              color: #2e2e2e;
            }

            .dateDay {
              font-size: 0.63rem;
              color: #767676;
            }

            .contenBox {
              margin-top: 0.88rem;
              width: 100%;

              .txt {
                font-size: 0.88rem;
                color: #2e2e2e;
                margin-bottom: 0.63rem;
              }

              .contenImg {
                display: flex;
                justify-content: flex-start;

                img {
                  width: 3rem;
                  height: 3rem;
                  background-color: #c1c1c1;
                  border-radius: 0.13rem;
                  margin: 0;
                  margin-right: 0.25rem;
                }
              }
            }
          }

          .image {
            width: 1.88rem;
            height: 1.88rem;
            background-color: #b5b5b5;
            border-radius: 50%;
            margin-right: 0.63rem;

            img {
              width: 1.88rem;
              height: 1.88rem;
              border-radius: 50%;
            }
          }

          .reply {
            font-size: 0.69rem;
            line-height: 1.27rem;
            letter-spacing: 0.02rem;
            color: #f15353;
          }
        }
      }
    }
  }
}
.replyInp-right{
  flex:1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  color: #00001C;
  .iconfont {
    font-size: 1.25rem;
  }
  .icon-dianzan,.icon-comment{
    margin-right: 0.375rem;
  }
  .icon-zb_like{
    font-size: 1.375rem;
    color: #F15353;
  }
  .icon-comment{
    margin-left: 1rem;
  }
  .icon-fontclass-fenxiang2222,.icon-bc_pay_discount{
    font-size: 1.75rem;
    margin-right: 1rem;
  }
}

.activityItem {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-row-gap: 10px;
  grid-column-gap: 10px;

  .acitem {
    font-size: 0.625rem;
    padding: 0.5rem 0;
    border-radius: 12px 12px 12px 12px;
    border: 1px solid #D6D6DC;
    display: flex;
    flex-direction: column;
    justify-content: center;
    .right {
      color: #999999;
    }
    input {
      border: none;
      width: 100%;
      padding: 0 0.5rem;
      text-align: center;
    }
  }
  .activeAcitemStyle {
    border-color: #F15353;
    background: #FEEDED;
    color: #F15353;
  }
}
</style>
